﻿namespace Devonline.Entity;

/// <summary>
/// 客户端, 字符主键的默认实现
/// </summary>
[Table("client"), DisplayName("客户端")]
public class Client : Client<string>, IEntitySet, IEntitySetWithCreate, IEntitySetWithCreateAndUpdate
{
    /// <summary>
    /// 客户端所有者
    /// </summary>
    public virtual Personal? Personal { get; set; }
}

/// <summary>
/// 客户端附加信息
/// </summary>
[Table("client_additional"), DisplayName("客户端附加信息")]
public class ClientAdditional : ClientAdditional<string>, IAdditional, IEntitySet, IEntitySetWithCreate
{
    public virtual Client? Additional { get; set; }
}

/// <summary>
/// 客户端
/// </summary>
/// <typeparam name="TKey"></typeparam>
[Table("client"), DisplayName("客户端")]
public abstract class Client<TKey> : EntitySetWithCreateAndUpdate<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey>, IEntitySetWithCreateAndUpdate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 客户端所有者编号
    /// </summary>
    [Column("personal_id"), DisplayName("客户端所有者编号"), Required, MaxLength(36), Excel]
    public virtual TKey? PersonalId { get; set; }
    /// <summary>
    /// 客户端类型
    /// </summary>
    [Column("type", TypeName = "VARCHAR(16)"), DisplayName("客户端类型"), Required, Excel]
    public virtual ClientType Type { get; set; }
    /// <summary>
    /// 客户端上名字
    /// </summary>
    [Column("name"), DisplayName("客户端姓名"), Required, MaxLength(256), Excel]
    public virtual string? Name { get; set; }
    /// <summary>
    /// 客户端号码
    /// </summary>
    [Column("code"), DisplayName("客户端编号"), MaxLength(36), Unique, Excel]
    public virtual string? Code { get; set; }
}

/// <summary>
/// 客户端附加信息
/// </summary>
public abstract class ClientAdditional<TKey> : Additional<TKey>, IAdditional<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible { }